package com.demo.validator.user;

import com.demo.constant.ErrorInfo;
import com.demo.validator.BaseValidator;
import com.jfinal.core.Controller;

public class addOrUpdate extends BaseValidator {

	@Override
	protected void validate(Controller c) {
		super.validate(c);
		if ("/user/update".equals(getActionKey())) {
			validateInteger("id", ErrorInfo.ERR_USER_ID_NOT_EMPTY,
					ErrorInfo.getErrMsg(ErrorInfo.ERR_USER_ID_NOT_EMPTY));
		}
		validateRequiredString("username",
				ErrorInfo.ERR_USERNAME_NOT_EMPTY,
				ErrorInfo.getErrMsg(ErrorInfo.ERR_USERNAME_NOT_EMPTY));
		validateRequiredString("name", ErrorInfo.ERR_NAME_NOT_EMPTY,
				ErrorInfo.getErrMsg(ErrorInfo.ERR_NAME_NOT_EMPTY));
	}
}
